package com.fa.model
{
	import com.fa.map.Map;
	
	import flash.display.DisplayObject;
	import flash.display.Shape;
	import flash.display.Sprite;

	public class SnakeSegment extends Shape
	{
		public static var SPAN:int = 2;
		
		public static const LEFT:int = 1;
		public static const UP:int = 2;
		public static const RIGHT:int = 3;
		public static const DOWN:int = 4;
		
		private var col:int;
		private var row:int;
		private var dir:int;
		public var nextSeg:*;
		
		public function SnakeSegment(){
			super();
			
			this.graphics.beginFill(0x000000, 1);
			this.graphics.drawRect(SPAN, SPAN, Map.TILE_SIZE - SPAN * 2, Map.TILE_SIZE - SPAN * 2);
		}
		
		public function updatePosition():void
		{
			this.x = col * Map.TILE_SIZE;
			this.y = row * Map.TILE_SIZE;
		}
		
		public function getCol():int
		{
			return this.col;
		}
		
		public function setCol(col:int):void
		{
			if(col > Map.COL - 1)
			{
				col = 0;
			}
			
			if(col < 0)
			{
				col = Map.COL - 1;
			}
			
			this.col = col;
		}
		
		public function getRow():int
		{
			return this.row;
		}
		
		public function setRow(row:int):void
		{
			if(row > Map.ROW - 1)
			{
				row = 0;
			}
			
			if(row < 0)
			{
				row = Map.ROW - 1;
			}
			
			this.row = row;
		}
		
		public function getDirection():int
		{
			return this.dir;
		}
		
		public function setDirection(dir:int):void
		{
			this.dir = dir;
		}
	}
}